<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:mtg="http://www.patelski.myself/jsf"
	xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

	<ui:define name="body">

		<h:form id="userSearch" styleClass="edit">

			<rich:simpleTogglePanel label="User search parameters"
				switchType="ajax">
				<s:decorate template="layout/display.xhtml">
					<ui:define name="label">firstName</ui:define>
					<h:inputText id="firstName"
						value="#{userList.user.firstName}" />
				</s:decorate>
				<s:decorate template="layout/display.xhtml">
					<ui:define name="label">lastName</ui:define>
					<h:inputText id="lastName"
						value="#{userList.user.lastName}" />
				</s:decorate>
			</rich:simpleTogglePanel>

			<div class="actionButtons"><h:commandButton id="search"
				value="Search" action="/UserList.xhtml" /></div>

		</h:form>
		<h:form>
			<rich:panel>
				<f:facet name="header">User search results</f:facet>
				<div class="results" id="userList"><h:outputText
					value="No user exists"
					rendered="#{empty userList.resultList}" /> <rich:dataGrid
					value="#{userList.resultList}" var="user" columns="4"
					elements="12">

					<rich:panel styleClass="userQuickPanel">
						<f:facet name="header">
							<h:outputText value="#{user.firstName} #{user.lastName}"></h:outputText>
						</f:facet>
						<h:panelGrid columns="2">
							<h:panelGrid columns="1">
								<h:outputText value="Naam:" styleClass="label"></h:outputText>
								<h:outputText value="#{user.firstName} #{user.lastName}" />
								<s:button view="/#{empty from ? 'User' : from}.xhtml"
									value="Select" id="user">
									<f:param name="userId" value="#{user.id}" />
								</s:button>
							</h:panelGrid>
							<s:link view="/#{empty from ? 'User' : from}.xhtml"
								id="userPic">
								<f:param name="userId" value="#{user.id}" />
								<rich:panel>
									<mtg:photo src="#{user.picture}" />
								</rich:panel>
							</s:link>
						</h:panelGrid>
					</rich:panel>
					<f:facet name="footer">
						<rich:datascroller></rich:datascroller>
					</f:facet>
				</rich:dataGrid></div>
			</rich:panel>
		</h:form>
		<div class="tableControl"><s:link view="/UserList.xhtml"
			rendered="#{userList.previousExists}"
			value="#{messages.left}#{messages.left} First Page" id="firstPage">
			<f:param name="firstResult" value="0" />
		</s:link> <s:link view="/UserList.xhtml"
			rendered="#{userList.previousExists}"
			value="#{messages.left} Previous Page" id="previousPage">
			<f:param name="firstResult"
				value="#{userList.previousFirstResult}" />
		</s:link> <s:link view="/UserList.xhtml"
			rendered="#{userList.nextExists}"
			value="Next Page #{messages.right}" id="nextPage">
			<f:param name="firstResult" value="#{userList.nextFirstResult}" />
		</s:link> <s:link view="/UserList.xhtml"
			rendered="#{userList.nextExists}"
			value="Last Page #{messages.right}#{messages.right}" id="lastPage">
			<f:param name="firstResult" value="#{userList.lastFirstResult}" />
		</s:link></div>

		<s:div styleClass="actionButtons" rendered="#{empty from}">
			<s:button view="/UserEdit.xhtml" id="create"
				value="Create user">
				<f:param name="userId" />
			</s:button>
		</s:div>

	</ui:define>

</ui:composition>

